package com.wzy.controller;

import com.wzy.pojo.ExternalPopulation;
import com.wzy.pojo.ExternalPopulationInfo;
import com.wzy.service.ExternalPopulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/externalPopulation")
public class ExternalPopulationController {
    @Autowired
    private ExternalPopulationService externalPopulationService;
    @RequestMapping
    public String findAllE(Model model){
        List<ExternalPopulationInfo> externalPopulations = externalPopulationService.findAllExternalPopulationInfo();
        model.addAttribute("externalPopulations",externalPopulations);
        return "ExternalPopulation";
    }

    @RequestMapping("/updateE")
    public String updateE(ExternalPopulation externalPopulation){
        //System.out.println(externalPopulation);
        externalPopulationService.updateExternalPopulation(externalPopulation);
        System.out.println("updateSuccess");
        return "redirect:/externalPopulation" ;
    }
}
